/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Objects;

import Resources.Resource;
import GamePlay.CanvasGame;
import Resources.GameResource;
import javax.microedition.lcdui.Graphics;

/**
 *
 * @author ThanhTrung
 */
public class Bariel {

    private static final int SCR_H = 240;
    private static final int SCR_W = 320;
    private CanvasGame canvas;
    private int screen_x;
    private int screen_y;
    private int w;
    private int h;

    public Bariel(CanvasGame canvas) {
        this.canvas = canvas;
        this.screen_x = (Resource.getImage(GameResource.img, GameResource.IMG_BG_PLAY).getWidth() - Resource.getImage(GameResource.img, GameResource.IMG_BARIEL).getWidth() - 10) / 2;
        this.screen_y = SCR_H - Resource.getImage(GameResource.img, GameResource.IMG_BARIEL).getHeight()-10;
        this.w = Resource.getImage(GameResource.img, GameResource.IMG_BARIEL).getWidth();
        this.h = Resource.getImage(GameResource.img, GameResource.IMG_BARIEL).getHeight();

    }

    public CanvasGame getCanvas() {
        return canvas;
    }

    public void setCanvas(CanvasGame canvas) {
        this.canvas = canvas;
    }

    public int getH() {
        return h;
    }

    public void setH(int h) {
        this.h = h;
    }

    public int getScreen_x() {
        return screen_x;
    }

    public void setScreen_x(int screen_x) {
        this.screen_x = screen_x;
    }

    public int getScreen_y() {
        return screen_y;
    }

    public void setScreen_y(int screen_y) {
        this.screen_y = screen_y;
    }

    public int getW() {
        return w;
    }

    public void setW(int w) {
        this.w = w;
    }

    public void paint(Graphics g) {
        //    if (screen_x > canvas.getResource().getIMG(Resource.IMG_BACKGROUND1).getWidth() - canvas.getResource().getIMG(Resource.IMG_BARIEL).getWidth()-5) {
        //       screen_x = canvas.getResource().getIMG(Resource.IMG_BACKGROUND1).getWidth() - canvas.getResource().getIMG(Resource.IMG_BARIEL).getWidth()-5;
        //  }
        if (screen_x > Resource.getImage(GameResource.img, GameResource.IMG_BACKGROUND).getWidth() - Resource.getImage(GameResource.img, GameResource.IMG_BARIEL).getWidth()-5) {
            screen_x = Resource.getImage(GameResource.img, GameResource.IMG_BACKGROUND).getWidth() - Resource.getImage(GameResource.img, GameResource.IMG_BARIEL).getWidth()-5;
        }
        if (screen_x < 5) {
            screen_x = 5;
        }
        g.drawImage(Resource.getImage(GameResource.img, GameResource.IMG_BARIEL), screen_x, screen_y,Graphics.TOP|Graphics.LEFT);        
    }
}
